Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geojson

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson

Turn your geo data into GeoJSON

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
261K
decreased by-5.59%
Maintainers
1
Weekly downloads
 
Created

What is geojson?

The geojson npm package provides utilities for working with GeoJSON data, which is a format for encoding a variety of geographic data structures. It allows you to create, manipulate, and validate GeoJSON objects easily.

What are geojson's main functionalities?

Creating GeoJSON Objects

This feature allows you to create GeoJSON objects from an array of data points. The example demonstrates how to convert an array of locations with latitude and longitude into a GeoJSON object.

const geojson = require('geojson');
const data = [
  { name: 'Location 1', lat: 40.7128, lng: -74.0060 },
  { name: 'Location 2', lat: 34.0522, lng: -118.2437 }
];
const geojsonData = geojson.parse(data, { Point: ['lat', 'lng'] });
console.log(JSON.stringify(geojsonData, null, 2));

Validating GeoJSON Objects

This feature allows you to validate GeoJSON objects to ensure they conform to the GeoJSON specification. The example shows how to validate a GeoJSON object representing a point feature.

const geojson = require('geojson');
const geojsonData = {
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      geometry: {
        type: 'Point',
        coordinates: [-74.0060, 40.7128]
      },
      properties: {
        name: 'Location 1'
      }
    }
  ]
};
const isValid = geojson.isValid(geojsonData);
console.log(isValid);

Converting GeoJSON to Other Formats

This feature allows you to convert GeoJSON objects to other formats such as KML. The example demonstrates how to convert a GeoJSON object to KML format.

const geojson = require('geojson');
const geojsonData = {
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      geometry: {
        type: 'Point',
        coordinates: [-74.0060, 40.7128]
      },
      properties: {
        name: 'Location 1'
      }
    }
  ]
};
const kml = geojson.toKML(geojsonData);
console.log(kml);

Other packages similar to geojson

Keywords

FAQs

Package last updated on 06 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc